1 Getting started
1.1 Build a Reference Database
The build_ref_db()
function constructs a reference database from functional annotations and taxonomic classifications.
library(f3mr)
library(here)
# Paths to annotation files
<- here::here("data-raw/meat_ref_db/f3m_meat_genes_catalog_20241211_funct_annotations.tsv")
funct_annotations_path <- here::here("data-raw/meat_ref_db/meat_genes_catalog_gtdb_classification.tsv")
gtdb_classification_path
# Build the reference database
<- build_ref_db(
meat_ref_db funct_annotations_path = funct_annotations_path,
gtdb_classification_path = gtdb_classification_path
)
# Preview the functional annotations
head(meat_ref_db$funct_annotations)
1.2 Import Sample Counts
The import_sample_count()
function reads and formats sample count data from a file.
# Path to sample count file
<- here::here("data-raw/smfood/mRNA-SMF01-MAP-AB-T06_genes_abundancies_with_species_and_functions.tsv")
sample_count_path
# Import sample count
<- import_sample_count(sample_count_path = sample_count_path)
sample_count
# Preview sample count
head(sample_count)
1.3 Aggregate Counts
The aggregate_counts()
function aggregates counts at specified taxonomic and functional levels.
# Define aggregation levels
<- "genus"
taxonomic_level <- "food_microbiome_metabolic_function"
functional_level
# Aggregate counts
<- aggregate_counts(
aggregated_counts all_sample_counts = all_sample_counts,
ref_db = meat_ref_db,
taxonomic_level = taxonomic_level,
functional_level = functional_level
)
# Preview aggregated counts
head(aggregated_counts)
1.4 Build a Count Matrix
The build_count_matrix()
function creates a count matrix suitable for downstream analyses such as DESeq2.
# Build count matrix
<- build_count_matrix(
count_matrix aggregated_counts = aggregated_counts,
deseq2 = TRUE
)
# Preview count matrix
head(count_matrix)
1.5 Usage Workflow
Below is a step-by-step guide to using the package:
Build the reference database:
<- build_ref_db(funct_annotations_path, gtdb_classification_path) meat_ref_db
Import multiple sample count files:
<- import_multiple_samples(folder_path) all_sample_counts
Aggregate counts:
<- aggregate_counts( aggregated_counts all_sample_counts = all_sample_counts, ref_db = meat_ref_db, taxonomic_level = "genus", functional_level = "food_microbiome_metabolic_function" )
Build a count matrix:
<- build_count_matrix(aggregated_counts, deseq2 = TRUE) count_matrix
Explore the count matrix:
head(count_matrix)